
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
  <meta charset="utf-8">
  <title>IOS App启动引导界面 - 许龙武的技术博客</title>
  <meta name="author" content="许龙武">

  
  <meta name="description" content="前言 由于之前一直都是用纯代码构建页面，一直没有学习怎么用storyboard。已经深深的感受到了纯代码写页面的繁琐了。所以这个Demo不但学习怎么用PageViewController实现启动引导的图片展示，也初步学习了怎么用storyboard构建页面。 构建storyboard &hellip;">
  

  <!-- http://t.co/dKP3o1e -->
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  
  <link rel="canonical" href="http://loongwoo.github.io/blog/2015/07/07/at-ios-appqi-dong-yin-dao-jie-mian/">
  <link href="/favicon.png" rel="icon">
  <link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
  <link href="/atom.xml" rel="alternate" title="许龙武的技术博客" type="application/atom+xml">
  <script src="/javascripts/modernizr-2.0.js"></script>
  <script src="http://cdn.staticfile.org/jquery/1.9.1/jquery.min.js"></script>
  <script>!window.jQuery && document.write(unescape('%3Cscript src="/javascripts/libs/jquery.min.js"%3E%3C/script%3E'))</script>
  <script src="/javascripts/octopress.js" type="text/javascript"></script>
  

</head>

<body   >
  <header role="banner"><hgroup>
  <h1><a href="/">许龙武的技术博客</a></h1>
  
    <h2>记录所学，快乐分享</h2>
  
</hgroup>

</header>
  <nav role="navigation"><ul class="subscription" data-subscription="rss">
  <li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
  
</ul>
  
<form action="https://www.google.com/search" method="get">
  <fieldset role="search">
    <input type="hidden" name="sitesearch" value="loongwoo.github.io">
    <input class="search" type="text" name="q" results="0" placeholder="Search"/>
  </fieldset>
</form>
  
<ul class="main-navigation">
	<li><a href="/">首页</a></li>
	<li><a href="/blog/archives">所有文章</a></li>
	<li><a href="http://weibo.com/loongwoo">我的微博</a></li>
</ul>

</nav>
  <div id="main">
    <div id="content">
      <div>
<article class="hentry" role="article">
  
  <header>
    
      <h1 class="entry-title">IOS App启动引导界面</h1>
    
    
      <p class="meta">
        




<time class='entry-date' datetime='2015-07-07T01:49:19+08:00'><span class='date'><span class='date-month'>Jul</span> <span class='date-day'>7</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>1:49 am</span></time>
        
      </p>
    
  </header>


<div class="entry-content"><h2>前言</h2>

<p>由于之前一直都是用纯代码构建页面，一直没有学习怎么用storyboard。已经深深的感受到了纯代码写页面的繁琐了。所以这个Demo不但学习怎么用PageViewController实现启动引导的图片展示，也初步学习了怎么用storyboard构建页面。</p>

<h2>构建storyboard</h2>

<p>先创建一个Single View Application，构建Main.storyboard，预览如下
<img src="/images/storyboard.png" alt="预览" />
除了最左的View Controller（根VC），新增了两个分别是右上Page View Controller和右下View Controller（内容VC）。</p>

<ol>
<li>确保勾选Use Auto Layout和Use Size Classes</li>
<li>关于Size Classes的讲解请参考<a href="http://www.cocoachina.com/ios/20141217/10669.html">链接1</a>，此处为了适配所有的设备，故选择了默认的w Any h Any</li>
<li>为内容VC添加一个Label和UIImageView，分别设置Constraints<br/>
鼠标右键点击Label拖动，在提示框选择Top Space to Top Layout Guide（IOS7中会自动向下移动20个像素）和Center Horizontally In Container（水平居中）。点击右边Edit可以设置具体的值。
<img src="/images/labelSC.png" alt="设置Label的约束" />
如下设置上下左右约束，Trailing Space to: superview（右）为-16；Leading Space to: superview（左）为-16；Top Space to: Label（上）为10，Button Space to: Bottom Layout Guide（下）为0；
<img src="/images/imageviewSC.png" alt="设置imageView的界限" /></li>
<li>为根VC添加一个Button，也设置好Constraints</li>
</ol>


<h2>代码实现</h2>

<h3>创建PageContentViewController</h3>

<p>连接内容VC和PageContentViewController.h，再连接好titleLabel和backgroundImageView，最后申明如下三个属性：</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='objectivec'><span class='line'><span class="k">@property</span> <span class="p">(</span><span class="k">weak</span><span class="p">,</span> <span class="k">nonatomic</span><span class="p">)</span> <span class="kt">IBOutlet</span> <span class="bp">UILabel</span> <span class="o">*</span><span class="n">titleLabel</span><span class="p">;</span>
</span><span class='line'><span class="k">@property</span> <span class="p">(</span><span class="k">weak</span><span class="p">,</span> <span class="k">nonatomic</span><span class="p">)</span> <span class="kt">IBOutlet</span> <span class="bp">UIImageView</span> <span class="o">*</span><span class="n">backgroundImageView</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">@property</span><span class="p">(</span><span class="k">assign</span><span class="p">,</span> <span class="k">nonatomic</span><span class="p">)</span> <span class="bp">NSUInteger</span> <span class="n">pageIndex</span><span class="p">;</span>
</span><span class='line'><span class="k">@property</span><span class="p">(</span><span class="k">copy</span><span class="p">,</span> <span class="k">nonatomic</span><span class="p">)</span> <span class="bp">NSString</span> <span class="o">*</span><span class="n">titleText</span><span class="p">;</span>
</span><span class='line'><span class="k">@property</span><span class="p">(</span><span class="k">copy</span><span class="p">,</span> <span class="k">nonatomic</span><span class="p">)</span> <span class="bp">NSString</span> <span class="o">*</span><span class="n">imageFile</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>PageContentViewController.m, 在viewDidLoad中添加</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='objectivec'><span class='line'><span class="nb">self</span><span class="p">.</span><span class="n">titleLabel</span><span class="p">.</span><span class="n">text</span><span class="o">=</span><span class="nb">self</span><span class="p">.</span><span class="n">titleText</span><span class="p">;</span>
</span><span class='line'><span class="nb">self</span><span class="p">.</span><span class="n">backgroundImageView</span><span class="p">.</span><span class="n">image</span><span class="o">=</span><span class="p">[</span><span class="bp">UIImage</span> <span class="nl">imageNamed</span><span class="p">:</span><span class="nb">self</span><span class="p">.</span><span class="n">imageFile</span><span class="p">];</span>
</span></code></pre></td></tr></table></div></figure>


<h3>ViewController</h3>

<p>ViewController.h中申请UIPageViewControllerDataSource，连接startBtn</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='objectivec'><span class='line'><span class="k">@interface</span> <span class="nc">ViewController</span> : <span class="bp">UIViewController</span><span class="o">&lt;</span><span class="bp">UIPageViewControllerDataSource</span><span class="o">&gt;</span>
</span><span class='line'>
</span><span class='line'><span class="o">-</span><span class="p">(</span><span class="kt">IBAction</span><span class="p">)</span><span class="nl">startWalkthrough</span><span class="p">:(</span><span class="kt">id</span><span class="p">)</span><span class="n">sender</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="k">@property</span> <span class="p">(</span><span class="k">strong</span><span class="p">,</span> <span class="k">nonatomic</span><span class="p">)</span> <span class="bp">UIPageViewController</span> <span class="o">*</span><span class="n">pageViewController</span><span class="p">;</span>
</span><span class='line'><span class="k">@property</span> <span class="p">(</span><span class="k">strong</span><span class="p">,</span> <span class="k">nonatomic</span><span class="p">)</span> <span class="bp">NSArray</span> <span class="o">*</span><span class="n">pageTitles</span><span class="p">;</span>
</span><span class='line'><span class="k">@property</span> <span class="p">(</span><span class="k">strong</span><span class="p">,</span> <span class="k">nonatomic</span><span class="p">)</span> <span class="bp">NSArray</span> <span class="o">*</span><span class="n">pageImages</span><span class="p">;</span>
</span><span class='line'><span class="k">@end</span>
</span></code></pre></td></tr></table></div></figure>


<p>ViewController.m, 实现UIPageViewControllerDateSource的四个方法</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
</pre></td><td class='code'><pre><code class='objectivec'><span class='line'><span class="cp">#pragma mark - Page View Controller Data Source</span>
</span><span class='line'>
</span><span class='line'><span class="p">-(</span><span class="bp">UIViewController</span> <span class="o">*</span><span class="p">)</span><span class="nf">pageViewController:</span><span class="p">(</span><span class="bp">UIPageViewController</span> <span class="o">*</span><span class="p">)</span><span class="nv">pageViewController</span> <span class="nf">viewControllerBeforeViewController:</span><span class="p">(</span><span class="bp">UIViewController</span> <span class="o">*</span><span class="p">)</span><span class="nv">viewController</span><span class="p">{</span>
</span><span class='line'>    <span class="bp">NSUInteger</span> <span class="n">index</span> <span class="o">=</span> <span class="p">((</span><span class="n">PageContentViewController</span><span class="o">*</span><span class="p">)</span> <span class="n">viewController</span><span class="p">).</span><span class="n">pageIndex</span><span class="p">;</span>
</span><span class='line'>    <span class="k">if</span> <span class="p">((</span><span class="n">index</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="n">index</span> <span class="o">==</span> <span class="n">NSNotFound</span><span class="p">))</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">return</span> <span class="nb">nil</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>    <span class="n">index</span><span class="o">--</span><span class="p">;</span>
</span><span class='line'>    <span class="k">return</span> <span class="p">[</span><span class="nb">self</span> <span class="nl">viewControllerAtIndex</span><span class="p">:</span><span class="n">index</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="p">-(</span><span class="bp">UIViewController</span> <span class="o">*</span><span class="p">)</span><span class="nf">pageViewController:</span><span class="p">(</span><span class="bp">UIPageViewController</span> <span class="o">*</span><span class="p">)</span><span class="nv">pageViewController</span> <span class="nf">viewControllerAfterViewController:</span><span class="p">(</span><span class="bp">UIViewController</span> <span class="o">*</span><span class="p">)</span><span class="nv">viewController</span><span class="p">{</span>
</span><span class='line'>    <span class="bp">NSUInteger</span> <span class="n">index</span> <span class="o">=</span> <span class="p">((</span><span class="n">PageContentViewController</span><span class="o">*</span><span class="p">)</span> <span class="n">viewController</span><span class="p">).</span><span class="n">pageIndex</span><span class="p">;</span>         
</span><span class='line'>    <span class="k">if</span> <span class="p">(</span><span class="n">index</span> <span class="o">==</span> <span class="n">NSNotFound</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">return</span> <span class="nb">nil</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>              
</span><span class='line'>    <span class="n">index</span><span class="o">++</span><span class="p">;</span>
</span><span class='line'>    <span class="k">if</span> <span class="p">(</span><span class="n">index</span> <span class="o">==</span> <span class="p">[</span><span class="nb">self</span><span class="p">.</span><span class="n">pageTitles</span> <span class="n">count</span><span class="p">])</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">return</span> <span class="nb">nil</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>    <span class="k">return</span> <span class="p">[</span><span class="nb">self</span> <span class="nl">viewControllerAtIndex</span><span class="p">:</span><span class="n">index</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="p">-(</span><span class="bp">NSInteger</span><span class="p">)</span><span class="nf">presentationCountForPageViewController:</span><span class="p">(</span><span class="bp">UIPageViewController</span> <span class="o">*</span><span class="p">)</span><span class="nv">pageViewController</span><span class="p">{</span>
</span><span class='line'>    <span class="k">return</span> <span class="p">[</span><span class="nb">self</span><span class="p">.</span><span class="n">pageTitles</span> <span class="n">count</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="p">-(</span><span class="bp">NSInteger</span><span class="p">)</span><span class="nf">presentationIndexForPageViewController:</span><span class="p">(</span><span class="bp">UIPageViewController</span> <span class="o">*</span><span class="p">)</span><span class="nv">pageViewController</span><span class="p">{</span>
</span><span class='line'>    <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>前面两个方法告诉PageViewController前一页或者后一页的显示内容；后两个方法告诉页面指示器（Page Indicator）的总页数和初始位置，当然只有在UIPageViewController的TransitionStyle为UIPageViewControllerTransitionStyleScroll的时候才有效。</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='objectivec'><span class='line'><span class="p">-(</span><span class="n">PageContentViewController</span> <span class="o">*</span><span class="p">)</span><span class="nf">viewControllerAtIndex:</span><span class="p">(</span><span class="bp">NSUInteger</span><span class="p">)</span><span class="nv">index</span><span class="p">{</span>
</span><span class='line'>    <span class="k">if</span> <span class="p">(([</span><span class="nb">self</span><span class="p">.</span><span class="n">pageTitles</span> <span class="n">count</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="o">||</span> <span class="p">(</span><span class="n">index</span> <span class="o">&gt;=</span> <span class="p">[</span><span class="nb">self</span><span class="p">.</span><span class="n">pageTitles</span> <span class="n">count</span><span class="p">]))</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">return</span> <span class="nb">nil</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>    <span class="c1">// Create a new view controller and pass suitable data.</span>
</span><span class='line'>    <span class="n">PageContentViewController</span> <span class="o">*</span><span class="n">pageContentViewController</span> <span class="o">=</span> <span class="p">[</span><span class="nb">self</span><span class="p">.</span><span class="n">storyboard</span> <span class="nl">instantiateViewControllerWithIdentifier</span><span class="p">:</span><span class="s">@&quot;PageContentViewController&quot;</span><span class="p">];</span>
</span><span class='line'>    <span class="n">pageContentViewController</span><span class="p">.</span><span class="n">imageFile</span> <span class="o">=</span> <span class="nb">self</span><span class="p">.</span><span class="n">pageImages</span><span class="p">[</span><span class="n">index</span><span class="p">];</span>
</span><span class='line'>    <span class="n">pageContentViewController</span><span class="p">.</span><span class="n">titleText</span> <span class="o">=</span> <span class="nb">self</span><span class="p">.</span><span class="n">pageTitles</span><span class="p">[</span><span class="n">index</span><span class="p">];</span>
</span><span class='line'>    <span class="n">pageContentViewController</span><span class="p">.</span><span class="n">pageIndex</span> <span class="o">=</span> <span class="n">index</span><span class="p">;</span>
</span><span class='line'>    <span class="k">return</span> <span class="n">pageContentViewController</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>该方法根据位置信息返回内容页面。</p>

<p>最后实现ViewDidLoad</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
</pre></td><td class='code'><pre><code class='objectivec'><span class='line'><span class="p">-(</span><span class="kt">void</span><span class="p">)</span><span class="nf">viewDidLoad</span><span class="p">{</span>
</span><span class='line'>    <span class="p">[</span><span class="nb">super</span> <span class="n">viewDidLoad</span><span class="p">];</span>
</span><span class='line'>    <span class="n">_pageTitles</span> <span class="o">=</span> <span class="l">@[</span> <span class="s">@&quot;帆船&quot;</span><span class="p">,</span> <span class="s">@&quot;美女&quot;</span><span class="p">,</span> <span class="s">@&quot;豪车&quot;</span><span class="p">,</span>  <span class="s">@&quot;碧海蓝天&quot;</span><span class="l">]</span><span class="p">;</span>
</span><span class='line'>    <span class="n">_pageImages</span> <span class="o">=</span> <span class="l">@[</span><span class="s">@&quot;page1.jpg&quot;</span><span class="p">,</span> <span class="s">@&quot;page2.jpg&quot;</span><span class="p">,</span> <span class="s">@&quot;page3.jpg&quot;</span><span class="p">,</span> <span class="s">@&quot;page4.jpg&quot;</span><span class="l">]</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1">// Create page view controller</span>
</span><span class='line'>    <span class="nb">self</span><span class="p">.</span><span class="n">pageViewController</span> <span class="o">=</span> <span class="p">[</span><span class="nb">self</span><span class="p">.</span><span class="n">storyboard</span> <span class="nl">instantiateViewControllerWithIdentifier</span><span class="p">:</span><span class="s">@&quot;PageViewController&quot;</span><span class="p">];</span>
</span><span class='line'>    <span class="nb">self</span><span class="p">.</span><span class="n">pageViewController</span><span class="p">.</span><span class="n">dataSource</span> <span class="o">=</span> <span class="nb">self</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">PageContentViewController</span> <span class="o">*</span><span class="n">startingViewController</span> <span class="o">=</span> <span class="p">[</span><span class="nb">self</span> <span class="nl">viewControllerAtIndex</span><span class="p">:</span><span class="mi">0</span><span class="p">];</span>
</span><span class='line'>    <span class="bp">NSArray</span> <span class="o">*</span><span class="n">viewControllers</span> <span class="o">=</span> <span class="l">@[</span><span class="n">startingViewController</span><span class="l">]</span><span class="p">;</span>
</span><span class='line'>    <span class="p">[</span><span class="nb">self</span><span class="p">.</span><span class="n">pageViewController</span> <span class="nl">setViewControllers</span><span class="p">:</span><span class="n">viewControllers</span> <span class="nl">direction</span><span class="p">:</span><span class="n">UIPageViewControllerNavigationDirectionForward</span> <span class="nl">animated</span><span class="p">:</span><span class="nb">NO</span> <span class="nl">completion</span><span class="p">:</span><span class="nb">nil</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1">// Change the size of page view controller</span>
</span><span class='line'>    <span class="nb">self</span><span class="p">.</span><span class="n">pageViewController</span><span class="p">.</span><span class="n">view</span><span class="p">.</span><span class="n">frame</span> <span class="o">=</span> <span class="n">CGRectMake</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nb">self</span><span class="p">.</span><span class="n">view</span><span class="p">.</span><span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">width</span><span class="p">,</span> <span class="nb">self</span><span class="p">.</span><span class="n">view</span><span class="p">.</span><span class="n">frame</span><span class="p">.</span><span class="n">size</span><span class="p">.</span><span class="n">height</span><span class="o">-</span><span class="mi">30</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>    <span class="p">[</span><span class="nb">self</span> <span class="nl">addChildViewController</span><span class="p">:</span><span class="n">_pageViewController</span><span class="p">];</span>
</span><span class='line'>    <span class="p">[</span><span class="nb">self</span><span class="p">.</span><span class="n">view</span> <span class="nl">addSubview</span><span class="p">:</span><span class="n">_pageViewController</span><span class="p">.</span><span class="n">view</span><span class="p">];</span>
</span><span class='line'>    <span class="p">[</span><span class="nb">self</span><span class="p">.</span><span class="n">pageViewController</span> <span class="nl">didMoveToParentViewController</span><span class="p">:</span><span class="nb">self</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<h2>效果展示</h2>

<p><img src="/images/xiaoguo1.png" alt="效果图1" /> <img src="/images/xiaoguo2.png" alt="效果图2" /></p>

<h2>项目源码</h2>

<p><a href="https://github.com/Loongwoo/PageViewDemo">PageViewDemo代码下载</a></p>

<h2>参考链接</h2>

<ol>
<li><a href="http://www.cocoachina.com/ios/20141217/10669.html">http://www.cocoachina.com/ios/20141217/10669.html</a></li>
<li><a href="http://www.kyleduo.com/?p=278">http://www.kyleduo.com/?p=278</a></li>
</ol>

</div>


  <footer>
    <p class="meta">
      
  

<span class="byline author vcard">Posted by <span class="fn">许龙武</span></span>

      




<time class='entry-date' datetime='2015-07-07T01:49:19+08:00'><span class='date'><span class='date-month'>Jul</span> <span class='date-day'>7</span><span class='date-suffix'>th</span>, <span class='date-year'>2015</span></span> <span class='time'>1:49 am</span></time>
      


      <br>原文链接：<a href="http://loongwoo.github.io/blog/2015/07/07/at-ios-appqi-dong-yin-dao-jie-mian/">http://loongwoo.github.io/blog/2015/07/07/at-ios-appqi-dong-yin-dao-jie-mian/</a>
 <!-- 添加这一行代码 -->
    </p>
    
      <div class="sharing">
  
  
  
  
  <!-- JiaThis Button BEGIN -->
<div class="jiathis_style_32x32">
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_renren"></a>
  <a href="http://www.jiathis.com/share?uid=2043882" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript">var jiathis_config = {data_track_clickback:'true'};</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=2043882" charset="utf-8"></script>
<!-- JiaThis Button END -->

<!--UY BEGIN -->
<div id="uyan_frame"></div>
<script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=2043882"></script>
<!--UY END -->

  
</div>

    
    <p class="meta">
      
        <a class="basic-alignment left" href="/blog/2015/07/06/at-ioszhong-propertyde-xiu-shi-zi/" title="Previous Post: IOS中Property的修饰字">&laquo; IOS中Property的修饰字</a>
      
      
        <a class="basic-alignment right" href="/blog/2015/07/07/at-ios-pdfxian-shi-he-liu-lan/" title="Next Post: IOS PDF显示和浏览">IOS PDF显示和浏览 &raquo;</a>
      
    </p>
  </footer>
</article>

</div>

<aside class="sidebar">
  
    <section>
  <h1>最新文章</h1>
  <ul id="recent_posts">
    
      <li class="post">
        <a href="/blog/2016/01/28/stringmanage-a-xcode-plugin-for-managing-your-strings/">StringManage -- a Xcode Plugin for Managing Your Strings</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/09/12/iosshi-yong-bundle/">iOS使用Bundle</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/09/12/iosduo-ge-localizable-dot-strings/">IOS多个Localizable.strings</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/09/11/iosxian-zhi-uitextfieldchang-du/">IOS限制UITextField长度</a>
      </li>
    
      <li class="post">
        <a href="/blog/2015/09/11/ioszi-dong-bu-ju-constraintswithvisualformat/">IOS自动布局constraintsWithVisualFormat</a>
      </li>
    
  </ul>
</section>




<section>
	<h1>关于我</h1>
    <p>程序员、创业者、IOS开发工程师
	<br/>新浪微博：<a href='http://weibo.com/loongwoo' target='_blank'>商陆_Xu</a>
	<br/>新浪博客：<a href="http://blog.sina.com.cn/lunaize" target="_blank" title="商陆的博客">商陆</a>
	<br/>GitHub：<a href='https://github.com/loongwoo' target='_blank'>Loongwoo</a>
	<br/>Git@OSC: <a href='http://git.oschina.net/redder_xu' target='_blank'>redder_xu</a>
    <br/>CSDN博客：<a href="http://blog.csdn.net/redder_xu" target="_blank" title="CSDN">霜叶红于二月花</a>
	<br/>个人微信：xulongwu77 欢迎调戏
	<br/><img width="220px" src="/images/myweixin.jpg" />
	</p>
</section>
<section>
  <h1>友情链接</h1>
  <ul>
  <li><a href="http://blog.devtang.com" target="_blank" title="唐巧的技术博客">唐巧的技术博客</a></li>
  <li><a href="http://www.leichunfeng.com" target="_blank" title="雷纯锋的技术博客">雷纯锋的技术博客</a></li>
  <li><a href="http://www.superqq.com" target="_blank" title=“刚刚在线”>刚刚在线</a></li>
  </ul>
</section>

  
</aside>


    </div>
  </div>
  <footer role="contentinfo"><p>
  Copyright &copy; 2017 - 许龙武 -
  <span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>
  <script language="javascript" type="text/javascript" src="http://js.users.51.la/17858326.js"></script>
<noscript><a href="http://www.51.la/?17858326" target="_blank"><img alt="&#x6211;&#x8981;&#x5566;&#x514D;&#x8D39;&#x7EDF;&#x8BA1;" src="http://img.users.51.la/17858326.asp" style="border:none" /></a></noscript>

</p>

</footer>
  











</body>
</html>
